package cn.com.dcsgo.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.sql.DataSource;

/**
 * 服务层配置
 *
 * @author Dcsgo
 * @since 2025/3/8 15:55
 */
@Configuration
@EnableAspectJAutoProxy
@EnableTransactionManagement
@ComponentScan({"cn.com.dcsgo.service"})
public class ServiceConfig {
    /**
     * 装配事务管理器
     *
     * @param dataSource dataSource
     * @return DataSourceTransactionManager
     */
    @Bean
    public DataSourceTransactionManager dataSourceTransactionManager(DataSource dataSource) {
        return new DataSourceTransactionManager(dataSource);
    }
}
